package one2Ten;

/**
 * 替换字符串中的空格为%20
 * Created by Wongy on 2018/3/9.
 * wozuo
 */
public class Four4 {
    private static String replaceSpace(String string) {
        if (string == null) {
            return null;
        }
        return string.replace(" ", "%20");
    }

    public static String replaceMethod(final String inputString) {
        return inputString.replace(" ", "%20");
    }

    //replace和replaceAll方法都会替换字符串中的全部，，对应replaceFirst方法
    //relaceAll接受正则表达式匹配
    public static void main(String[] args) {
        System.out.println("Four4.main , 13 : replaceSpace(\"11 11 11\") = " + replaceSpace("1 1 1"));
        String string = "We Are Happy";
        System.out.println(replaceMethod(string));
    }
}
